<?php

if (!defined('WPSR_ACCESS')) { exit; }
ini_set('memory_limit', '128M');

/**
 * WP Showroom Admin Page - Options
 *
 * @package
 */


require_once "wpsr.admin.php";

$wpsr = new WPsrAdm;
$wpsr->WPsrUser();


global $wpdb;

$wpsr->updateAlbList();

/*

$q = "select * from wpsr_pic order by pid";
$q = $wpdb->prepare($q);
$result = $wpdb->get_results($q);

foreach ($result as $res) {

		$file = $res->file;
		$date = date('Y-m-d H:i:s');
		$id = NULL;
		$type = 2;
		$owner = 1;
		$path = $res->path;
		$wpdb->insert(WPSR_DB_I, compact('id', 'date', 'type', 'owner', 'file', 'path'));

}




update wp_comments, wp_aniga_picture set wp_comments.pid = wp_aniga_picture.newid where wp_comments.com_id = wp_aniga_picture.pid


UPDATE wp_comments,
wpcomold SET wp_comments.com_id = wpcomold.comment_pid_ID WHERE wpcomold.comment_date = wp_comments.comment_date AND wp_comments.comment_author_IP = wpcomold.comment_author_IP



$q = "select * from wp_aniga_picture where pid >= 7000 and pid < 10000 order by pid";
$q = $wpdb->prepare($q);
$result = $wpdb->get_results($q);

foreach ($result as $res) {

		$date = $res->pic_date;
		$id = NULL;
		$type = 2;
		$owner = 1;
		$level = $res->level;
		$qu = $wpdb->insert(WPSR_DB_R, compact('id', 'type', 'date', 'owner', 'level'));

		$pid = (int) $wpdb->insert_id;
		$aid = $res->npaid;
		$file = $res->filename;
		if ($res->caption == '' || $res->caption === NULL) {
			$caption = NULL;
		}
		else {
			$caption = $res->caption;
		}
		$width = $res->width;
		$height = $res->height;
		$hits = $res->hits;
		$path = $res->path;
		
		$trans = array("http://www.animalbeach.net/gallery/" => "old/");
		$path = strtr($path, $trans);
		
		$qu = $wpdb->insert(WPSR_DB_P, compact('pid', 'aid', 'path', 'file', 'caption', 'width', 'height', 'hits'));

		$q = $wpdb->query("update wp_aniga_picture set newid = $pid where pid = $res->pid");
		
		echo "picture $res->filename $path $caption  <br/>";
}
*/

/*
$q = "select * from wp_aniga_relations where newpid IS 	NULL order by id";
$q = $wpdb->prepare($q);
$result = $wpdb->get_results($q);

foreach ($result as $res) {
	$q = "update wp_aniga_relations set newpid = (select newid from wp_aniga_relations2 where id = $res->parent_id) where id = $res->id";
	$q = $wpdb->query($q);
	
}
*/


/*

1) Albums

$q = "select * from wp_aniga_albums order by id";

$q = $wpdb->prepare($q);

$result = $wpdb->get_results($q);

foreach ($result as $res) {
	
		$title = stripslashes($res->name);
		$title = htmlspecialchars($title);
		
		$uri = $wpsr->adminAlbumUri($res->name);
		
		$desc = stripslashes($res->desc);
		$description = htmlspecialchars($desc);
		
		$meta = '';

		$parent = 1;

		$com = 1;
		$level = 0;

			$date = date('Y-m-d H:m:s');
			$id = NULL;
			$type = 1;
			$owner = 1;
			$ord = 0;
			$paid = 1;
			$wpdb->insert(WPSR_DB_R, compact('id', 'type', 'date', 'owner', 'level'));
			$aid = (int) $wpdb->insert_id;
			$wpdb->insert(WPSR_DB_A, compact('aid', 'paid', 'title', 'uri', 'description', 'ord', 'com', 'meta'));
		
		//neue id zurückschreiben
		$q = $wpdb->query("update wp_aniga_albums set newid = $aid where id = $res->id");
		$q = $wpdb->query("update wp_aniga_relations set newid = $aid where id = $res->id");
		$q = $wpdb->query("update wp_aniga_picture set npaid = $aid where parent_id = $res->id");
	echo "old: $res->id new: $aid <br/>";
}
*/




?>
<div id="wpbody">
	<div class="wrap">
		<h2>Gallery Options</h2>
	</div>
</div>